package web.pre;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import entity.Easybuy_product;
import entity.Easybuy_product_category;
import service.EasyBuyProductCategoryService;
import service.EasyBuyProductService;
import service.Impl.EasyBuyProductCategoryServiceImpl;
import service.Impl.EasyBuyProductServiceImpl;

/**
 * Servlet implementation class Product
 */
public class Product extends HttpServlet {
	private static final long serialVersionUID = 1L;
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		String action =request.getParameter("action");
		
		switch (action) {
		case "details":
			int id=Integer.parseInt(request.getParameter("id"));
			EasyBuyProductService service=new EasyBuyProductServiceImpl();
			Easybuy_product pro= service.ProductDetails(id);
			request.setAttribute("pro", pro);
			request.getRequestDispatcher("Product.jsp").forward(request, response);
			break;
			
		default:
			break;
		}
		
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
